package com.example.xd.javatest.build_test;

/**
 * @auther XuDan on 2020/6/16.
 * 组装各个组件,生成实类对象
 * 持有构建者对象,返回各个组件实例
 */
public class Director {
    private Builder mBuilder;

    public Director(Builder builder) {
        mBuilder = builder;
    }

    public Computer create() {
        Computer obj = new Computer();
        obj.setCpu(mBuilder.createCPU());
        obj.setMainBoard(mBuilder.createMainBoard());
        obj.setRam(mBuilder.createRam());
        return obj;
    }
}
